package javaEEBasic.day05;

public class Test02 {
    public static void main(String[] args) {
/*        Random random = new Random();
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(6);
        }
        printArr(arr);
        countNumber(arr);*/
        Teacher teacher1  = new Teacher("王老师",32);
        Teacher teacher2  = new Teacher("李老师",33);
        teacher1.show();
        teacher2.show();
    }

    public static void printArr(int[] arr) {
        if (arr == null || arr.length == 0) {
            throw new RuntimeException("参数错误");
        }
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.println(arr[i] + "]");
            } else {
                System.out.print(arr[i] + ",");
            }
        }
    }

    public static void countNumber(int[] arr) {
        if (arr == null || arr.length == 0) {
            throw new RuntimeException("参数错误");
        }
        int count0 = 0, count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0;
        for (int i = 0; i < arr.length; i++) {
            switch (arr[i]) {
                case 0:
                    count0++;
                    break;
                case 1:
                    count1++;
                    break;
                case 2:
                    count2++;
                    break;
                case 3:
                    count3++;
                    break;
                case 4:
                    count4++;
                    break;
                case 5:
                    count5++;
                    break;
                default:
                    System.out.println("数组元素异常");
                    break;
            }

        }
        if (count0 > 0) System.out.println("0出现了:" + count0 + "次");
        if (count1 > 0) System.out.println("1出现了:" + count1 + "次");
        if (count2 > 0) System.out.println("2出现了:" + count2 + "次");
        if (count3 > 0) System.out.println("3出现了:" + count3 + "次");
        if (count4 > 0) System.out.println("4出现了:" + count4 + "次");
        if (count5 > 0) System.out.println("5出现了:" + count5 + "次");
    }

    public static double taxiFare(double distance) {
        if (distance <= 0) {
            return 0;
        }
        if (distance <= 3) {
            return 11;
        } else {
            return 11 + (distance - 3) * 1.8;
        }
    }
}
